package tech.aistar.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import tech.aistar.interceptor.LoginInterceptor;

import java.util.List;


@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(
                loginInterceptor()).excludePathPatterns("/**");
//                loginInterceptor()).addPathPatterns("/**")
//                .excludePathPatterns("/user/login/**","/gedan/select/**","/song/**")
//                .excludePathPatterns("/plugins/**","/views/**");
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new HandlerArgsConfig());
    }
}